package com.leetcode.doublepoint;

/**
 * ArrayMulti..
 *
 * @author Lizhong
 * @date 2019/9/9
 */
public class ArrayMulti {
    static int maxAre(int[] height, int heightSize) {
        int i = 0;
        int j = heightSize - 1;
        int res = 0;
        while (i < j) {
            int h = height[i] > height[j] ? height[j] : height[i];
            res = res > h * (j - i) ? res : h * (j - i);
            if (height[i] < height[j])
                ++i;
            else
                --j;
        }
        return res;
    }

    public static void main(String[] args) {
        int m[] = {1, 8, 6, 2, 5, 4, 8, 3, 7};
        int re = maxAre(m, 9);
        System.out.println(re);
    }
}
